package com.gxa.exception;

import com.gxa.dto.ResultData;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author:IT-CNLM
 * @date:Created at 2020/07/23
 */
@RestControllerAdvice
public class MyExceptionHandler {

    /**
     * 数据异常助手
     * @param e
     * @return
     */
    @ExceptionHandler(DataException.class)
    public ResultData dataException(DataException e){
        return new ResultData(e.getCode(), e.getMsg());
    }


    /**
     * 异常助手
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    public ResultData systemException(Exception e){
        e.printStackTrace();
        return new ResultData(1009, e.getMessage());
    }


}
